package com.azxc.rapid.common.utils;

import com.azxc.rapid.system.user.cache.UserCache;
import com.azxc.rapid.system.user.entity.User;
import lombok.experimental.UtilityClass;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

@UtilityClass
public class UserUtil {
	public static String getRealName(Long userId) {
		if (StringUtils.isEmpty(userId)) {
			return "";
		}
		User user = UserCache.getUser(userId);
		Assert.isTrue(user != null, "系统提示：用户id = " + userId + " 未匹配到对应的用户，请联系管理员进行新增！");
		return user.getRealName();
	}

	public static String getPhone(Long userId) {
		if (StringUtils.isEmpty(userId)) {
			return "";
		}
		User user = UserCache.getUser(userId);
		Assert.isTrue(user != null, "系统提示：用户id = " + userId + " 未匹配到对应的用户，请联系管理员进行新增！");
		return user.getPhone();
	}
}
